package cn.ichiva.luckysheet.utils;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;

/**
 * TODO
 *
 * @author pzq
 * @version 1.0
 * @date 2022/1/28 11:00
 */
public class test3 {

    public static void main1(String[] args) {
        ExecutorService executorService=new ThreadPoolExecutor(
                2,
                5,
                3,
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardOldestPolicy()
//                new ThreadPoolExecutor.DiscardPolicy()
//                new ThreadPoolExecutor.CallerRunsPolicy()
//                new ThreadPoolExecutor.AbortPolicy() //
                );
        for (int i = 0; i < 20; i++) {
            executorService.execute(()->{
                System.out.println(Thread.currentThread().getName()+"ok");
            });
        }
    }

    public static void main(String[] args) {
        User u1=new User(1,"aba",10);
        User u2=new User(2,"abb",11);
        User u3=new User(3,"abc",12);
        User u4=new User(4,"abd",13);
        User u5=new User(5,"abe",14);
        User u6=new User(6,"abf",15);
       List<User> list= Arrays.asList(u1,u2,u3,u4,u5,u6);

        list.stream().filter(u ->{return u.getId()%2==0;})
                .filter(u->{return u.getAge()>10;})
                .map(u->{return u.getName().toUpperCase();})
                .sorted((us1,us2)->{return us2.compareTo(us1);})
                .limit(1)
                .forEach(System.out::println);
    }
}
